<template>
  <div class="el-dialog" v-if="visible">
    <div class="el-dialog_title">{{title}}</div>
    <div class="el-dialog_content">{{content}}</div>
    <div class="el-dialog_btns">
      <span @click="leftFn">{{left.text}}</span>
      <span @click="rightFn">{{right.text}}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: 'el-dialog',
  methods: {
    hideDialog() {
      this.$emit('update:visible', false);
      return this;
    },
    leftFn() {
      this.hideDialog().left.cb();
    },
    rightFn() {
      this.hideDialog().right.cb();
    },
  },
  props: ['title', 'content', 'left', 'right', 'visible'],
};
</script>

<style lang="scss" scoped>
.el-dialog{
  padding-top: 12px;
  width: 80vw;
  max-width: 300px;
  border-radius: 3px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  background: #fff;
  color: #444;
  text-align: center;
  overflow: hidden;
  .el-dialog_title{
    letter-spacing: 2px;
  }
  .el-dialog_content{
    padding: 12px;
    line-height: 1.4;
  }
  .el-dialog_btns{
    border-top: 1px solid #ccc;
    font-size: 0;
    span{
      display: inline-block;
      width: 50%;
      line-height: 30px;
      font-size: 15px;
    }
    span:first-child{
      border-right: 1px solid #ccc;
      box-sizing: border-box;
    }
  }
}
</style>
